package top.italks.manufactureproject.utils;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import top.italks.manufactureproject.constant.ApiService;
import top.italks.manufactureproject.constant.Config;

public class RetrofitService {

    private static Retrofit retrofit;
    private static OkHttpClient client;
    private static Retrofit getInstance() {
        if (retrofit == null) {
            OkHttpClient.Builder builder = new OkHttpClient.Builder();
            client = builder.build();
            retrofit = new Retrofit.Builder()
                .baseUrl(Config.url)
                .addConverterFactory(GsonConverterFactory.create())
                .client(client)
                .build();
        }
        return retrofit;
    }

    public static ApiService getApiService() {
        return getInstance().create(ApiService.class);
    }


}
